package movee.utils.collection;


import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

public final class SetUtils {

    private SetUtils() { }

    @SafeVarargs
    public static <T> Set<T> newHashSetOfUnion(Collection<T>...origins) {
        Set<T> result = new HashSet<>();
        for (Collection<T> origin : origins) {
            result.addAll(origin);
        }
        return result;
    }

    public static <T> Set<T> newHashSetOfIntersection(Collection<T> src, Collection<T> dst) {
        Set<T> result = new HashSet<>(src);
        result.retainAll(dst);
        return result;
    }

    public static <T> Set<T> newHashSetOfDifference(Collection<T> src, Collection<T> dst) {
        Set<T> result = new HashSet<>(src);
        result.removeAll(dst);
        return result;
    }
}
